package com.miszczu.model;
// Generated 2012-03-05 20:16:25 by Hibernate Tools 3.4.0.CR1


import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 * Classes generated by hbm2java
 */
@Entity
@Table(name="classes"
    ,catalog="dziennik"
)
public class Classes  implements java.io.Serializable {

	 @Transient
	 public Long getStudentsInClass() {
		return studentsInClass;
	}

	@Transient
	public void setStudentsInClass(Long studentsInClass) {
		this.studentsInClass = studentsInClass;
	}
	
	@Transient
	private Long studentsInClass;
	
	@Transient
	public Long getTeachersInClass() {
		return teachersInClass;
	}
	
	@Transient
	public void setTeachersInClass(Long teachersInClass) {
		this.teachersInClass = teachersInClass;
	}
	
	@Transient
	private Long teachersInClass;
	
     private Integer classId;
     private String className;
     private String classDescription;
     private Set<Messages> messageses = new HashSet<Messages>(0);
     private Set<Users> userses = new HashSet<Users>(0);
     private Set<Subjects> subjectses = new HashSet<Subjects>(0);

    public Classes() {
    }

	
    public Classes(String className) {
        this.className = className;
    }
    public Classes(String className, String classDescription, Set<Messages> messageses, Set<Users> userses, Set<Subjects> subjectses) {
       this.className = className;
       this.classDescription = classDescription;
       this.messageses = messageses;
       this.userses = userses;
       this.subjectses = subjectses;
    }
   
     @Id @GeneratedValue(strategy=IDENTITY)

    
    @Column(name="class_id", unique=true, nullable=false)
    public Integer getClassId() {
        return this.classId;
    }
    
    public void setClassId(Integer classId) {
        this.classId = classId;
    }

    
    @Column(name="class_name", nullable=false, length=45)
    public String getClassName() {
        return this.className;
    }
    
    public void setClassName(String className) {
        this.className = className;
    }

    
    @Column(name="class_description", length=100)
    public String getClassDescription() {
        return this.classDescription;
    }
    
    public void setClassDescription(String classDescription) {
        this.classDescription = classDescription;
    }

@OneToMany(fetch=FetchType.LAZY, mappedBy="classes")
    public Set<Messages> getMessageses() {
        return this.messageses;
    }
    
    public void setMessageses(Set<Messages> messageses) {
        this.messageses = messageses;
    }

@ManyToMany(fetch=FetchType.LAZY, mappedBy="classeses")
@Cascade({CascadeType.ALL})
    public Set<Users> getUserses() {
        return this.userses;
    }
    
    public void setUserses(Set<Users> userses) {
        this.userses = userses;
    }

@ManyToMany(fetch=FetchType.EAGER)
    @JoinTable(name="classessubjects", catalog="dziennik", joinColumns = { 
        @JoinColumn(name="Classes_class_id", nullable=false, updatable=false) }, inverseJoinColumns = { 
        @JoinColumn(name="Subjects_subject_id", nullable=false, updatable=false) })
    public Set<Subjects> getSubjectses() {
        return this.subjectses;
    }
    
    public void setSubjectses(Set<Subjects> subjectses) {
        this.subjectses = subjectses;
    }

    @Override
    public boolean equals(Object obj) {
    	// TODO Auto-generated method stub
    	Classes objClass = (Classes) obj;
    	
    	if(objClass.getClassId() == this.getClassId()) {
    		return true;
    	}
    	
    	return false;
    	
    }


}


